import React from 'react';
import './index.css';
import 'antd/dist/antd.less';
import { BrowserRouter, browserHistory } from "dva/router";
import createHistory from "history/createBrowserHistory";
import Loadable from 'react-loadable';
import Test from "./pages/content/modal";
import Routes from './routes';
import dva from "dva";

const initState = window.__INITIAL_STATE__;

const app = dva({
    history: createHistory(),
    initialState: initState,
    onError: error => {
        console.log(error.message);
    }
});

app.model(Object.assign({}, Test));
app.router(() => {
    return (
        <BrowserRouter history={browserHistory} >
            <Routes history={createHistory()} />
        </BrowserRouter>
    );
});

window.main = () => {
    Loadable.preloadReady().then(() => {
        app.start('#app');
    });
}